<?php
declare (strict_types = 1);

namespace app\middleware;

class Check
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        // dump($request->action());
        // dump($request->post());
        // dump($request->param());
        // dump($request->header());

        // 定义参数
        $request->inApp = "PC";

        // 重定向到action=think
        if ($request->param('name') == 'think') {
            return redirect('/api/index/think');
        }

        return $next($request);
    }


    // 结束调度
    public function end(\think\Response $response)
    {
        // 回调行为
    }
}
